clear

capture log close
cd "/Users/d31713r/Documents/Experiments in Politics/2022 final study/"

log using "experiments2022.txt", replace text
use "experiments2022.dta" 

*attention check drops

drop if att_check_1_2<9 | att_check_1_2>10
drop if att_check_2_6<4 | att_check_2_6>5

*manipulated variables

*An indicator that takes the value of 1 if the respondent is randomly assigned to the fact-check condition and 0 otherwise (FC). 

destring treatment_group, replace
gen FC=(treatment_group==2)

*An indicator that takes the value of 1 if the respondent is randomly assigned to any state-media tag condition and 0 otherwise (SM_all).

gen SM_all=(treatment_group>2)

*An indicator that takes the value of 1 if the respondent is randomly assigned to the Serbian state-media tag condition and 0 otherwise (Serbia_SM).

gen Serbia_SM=(treatment_group==4)

*An indicator that takes the value of 1 if the respondent is randomly assigned to the Chinese state-media tag condition and 0 otherwise (China_SM).

gen China_SM=(treatment_group==3)

*An indicator that takes the value of 1 if the respondent is randomly assigned to the unlabeled state-media tag condition and 0 otherwise (unlabeled_SM).

gen unlabeled_SM=(treatment_group==5)

*measured variables

*… participants' favorability of China and Serbia on a 4 point scale where 1 = "Very unfavorable" and 4 = "Very favorable" (China_feelings and Serbia_feelings, respectively). 

gen China_feelings=abs(country_fave_1-5) /*flip scale*/
tab China_feelings

gen Serbia_feelings=abs(country_fave_2-5) /*flip scale*/
tab Serbia_feelings

*… whether participants have heard of the Global Times news before—coded as a binary variable where 0 = never heard and 1 = has heard. 

gen GT_know=(globaltimes_check_8==1) 
tab GT_know

tab globaltimes_check_9 /*compare with fake outlet*/

*… how much trust and confidence participants have in mass media (newspaper, TV, radio, and social media) on a 4 point scale where 1 = "Not at all" and 4 = "A great deal". 

rename media_trust media_trust_old
gen media_trust=abs(media_trust_old-5) /*flip scale*/
tab media_trust

*…how much trust and confidence participants have in state-affiliated media on a 4 point scale where 1 = "Not at all" and 4 = "A great deal".

rename state_media_trust state_media_trust_old
gen state_media_trust=abs(state_media_trust_old-5) /*flip scale*/
tab state_media_trust

*… how much trust people have in independent fact-checking organizations' evaluations of the accuracy of claims made online on a 4-point scale where 1 = "Not at all" and 4 = "A great deal".

rename fact_check_trust fact_check_trust_old
gen fact_check_trust=abs(fact_check_trust_old-5) /*flip scale*/
tab fact_check_trust

*… how frequently participants use Twitter on a 7-point scale where 1 =  "Never" and 7 =  "Daily". 

/*messy - requires manual recode*/
rename twitter_usage twitter_usage_old
gen twitter_usage=.
replace twitter_usage=1 if twitter_usage_old==3
replace twitter_usage=2 if twitter_usage_old==2
replace twitter_usage=3 if twitter_usage_old==7
replace twitter_usage=4 if twitter_usage_old==6
replace twitter_usage=5 if twitter_usage_old==5
replace twitter_usage=6 if twitter_usage_old==4
replace twitter_usage=7 if twitter_usage_old==1
tab twitter_usage

*how frequently participants read political news on Twitter where 1 = "Never" and 7 = "Daily".

rename twitter_pol_usage twitter_pol_usage_old
gen twitter_pol_usage=abs(twitter_pol_usage_old-8) /*flip scale*/
replace twitter_pol_usage=1 if twitter_usage==1
tab twitter_pol_usage

*lasso demographics

*Education (college graduate indicator) (factor variable)

gen college=(edu>4 & edu<8) if edu!=. /*1 if bachelors or greater, 0 otherwise)*/
tab college

*Age group (18-24, 25-34, 35-44, 45-54, 55-64, 65+) (factor variable)

*use i.age
tab age

*Male (1/0) (factor variable)

gen male=(gender==1) if gender!=.
tab male

*Political interest (five-point)

rename pol_interest pol_interest_old
gen pol_interest=abs(pol_interest_old-6) /*flip scale*/
tab pol_interest

*Non-Hispanic white (1/0) (factor variable)

egen anyrace=rowtotal(race_*) /*counts who is not missing - i.e., they indicated at least one racial group*/
gen nonhisp_white=(race_5==1 & hisp==2) if anyrace>0 & hisp!=.
tab nonhisp_white

*Media outlet familiarity (indicators for each outlet listed; factor variables)

*We will create an indicator for Democrats that takes the value of 1 for people who identify as Democrat or lean Democrat and 0 otherwise and an indicator of Republicans that takes the value of 1 for people who identify as Republican or lean Republican and 0 otherwise.

gen dem=(party==2 | ind_party==2)
gen rep=(party==1 | ind_party==1)

tab dem
tab rep

*outcomes

*false_SM = mean perceived accuracy of false tweets from a state media outlet
*true_SM = mean perceived accuracy of true tweets from a state media outlet
*true_post_FC = mean perceived accuracy of true tweets shown after a fact check
*the perceived accuracy of each tweet on a four-point scale where 1 = "Not at all accurate" and 4 = "Very accurate". (Indices for mean accuracy by type of tweet are reported under indices below.)

/*flip scale for all headline accuracy variables*/
foreach var of varlist NT_nonsm_misinfo_1 NT_nonsm_misinfo_2 NT_nonsm_misinfo_3 NT_nonsm_true_1 NT_nonsm_true_2 NT_nonsm_true_3 NT_nonsm_true_4 NT_nonsm_true_5 NT_nonsm_true_6 NT_nonsm_true_7 NT_sm_china_misinfo NT_sm_china_true NT_sm_generic_misinf NT_sm_generic_true NT_sm_serbia_misinfo NT_sm_serbia_true FC_nonsm_misinfo_1 FC_nonsm_misinfo_2 FC_nonsm_misinfo_3 FC_nonsm_true_1 FC_nonsm_true_2 FC_nonsm_true_3 FC_nonsm_true_4 FC_nonsm_true_5 FC_nonsm_true_6 FC_nonsm_true_7 FC_sm_china_misinfo FC_sm_china_true FC_sm_generic_misinf FC_sm_generic_true FC_sm_serbia_misinfo FC_sm_serbia_true SM_C_nonsm_misinfo_1 SM_C_nonsm_misinfo_2 SM_C_nonsm_misinfo_3 SM_C_nonsm_true_1 SM_C_nonsm_true_2 SM_C_nonsm_true_3 SM_C_nonsm_true_4 SM_C_nonsm_true_5 SM_C_nonsm_true_6 SM_C_nonsm_true_7 SM_C_china_misinfo SM_C_china_true SM_C_gen_misinfo SM_C_gen_true SM_C_serb_misinfo SM_C_serb_true SM_S_nonsm_misinfo_3 SM_S_nonsm_true_1 SM_S_nonsm_true_2 SM_S_nonsm_true_3 SM_S_nonsm_true_4 SM_S_nonsm_true_5 SM_S_nonsm_true_6 SM_S_nonsm_true_7 SM_S_chi_misinfo SM_S_chi_true SM_S_gen_misinfo SM_S_gen_true SM_S_serb_misinfo SM_S_serb_true SM_N_nonsm_misinfo_1 SM_N_nonsm_misinfo_2 SM_N_nonsm_misinfo_3 SM_N_nonsm_true_1 SM_N_nonsm_true_2 SM_N_nonsm_true_3 SM_N_nonsm_true_4 SM_N_nonsm_true_5 SM_N_nonsm_true_6 SM_N_nonsm_true_7 SM_N_chi_misinfo SM_N_chi_true SM_N_gen_misinfo SM_N_gen_true SM_N_serb_misinfo SM_N_serb_true {
	rename `var' old`var' 
	recode old`var' (1=4 "Very accurate") (2=3 "Somewhat accurate") (3=2 "Not very accurate") (4=1 "Not at all acccurate"), gen(`var')
} 

/*count how many ratings answers selected for SM_S_total1*/
egen SM_S_total1=rowtotal(SM_S_nonsm_misinfo_1*)

/*make new single value variable for people who only picked one answer*/
gen SM_S_nonsm_misinfo_1=.
replace SM_S_nonsm_misinfo_1=4 if SM_S_nonsm_misinfo_1_1==1 & SM_S_total1==1
replace SM_S_nonsm_misinfo_1=3 if SM_S_nonsm_misinfo_1_2==1 & SM_S_total1==1
replace SM_S_nonsm_misinfo_1=2 if SM_S_nonsm_misinfo_1_3==1 & SM_S_total1==1
replace SM_S_nonsm_misinfo_1=1 if SM_S_nonsm_misinfo_1_4==1 & SM_S_total1==1

/*take mean of responses if selected more than one*/

/*first replace with the values i want to average*/
replace SM_S_nonsm_misinfo_1_1=4 if SM_S_nonsm_misinfo_1_1==1 
replace SM_S_nonsm_misinfo_1_2=3 if SM_S_nonsm_misinfo_1_2==1 
replace SM_S_nonsm_misinfo_1_3=2 if SM_S_nonsm_misinfo_1_3==1 
replace SM_S_nonsm_misinfo_1_4=1 if SM_S_nonsm_misinfo_1_4==1 

/*then take mean and replace into new variable*/
egen SM_S_nonsm_misinfo_1_mean=rowmean(SM_S_nonsm_misinfo_1_*) if SM_S_total1==2
replace SM_S_nonsm_misinfo_1=SM_S_nonsm_misinfo_1_mean if SM_S_total1==2
su SM_S_nonsm_misinfo_1

/*count how many ratings answers selected for SM_S_total2*/
egen SM_S_total2=rowtotal(SM_S_nonsm_misinfo_2*)

/*make new single value variable for people who only picked one answer*/
gen SM_S_nonsm_misinfo_2=.
replace SM_S_nonsm_misinfo_2=4 if SM_S_nonsm_misinfo_2_1==1 & SM_S_total2==1
replace SM_S_nonsm_misinfo_2=3 if SM_S_nonsm_misinfo_2_2==1 & SM_S_total2==1
replace SM_S_nonsm_misinfo_2=2 if SM_S_nonsm_misinfo_2_3==1 & SM_S_total2==1
replace SM_S_nonsm_misinfo_2=1 if SM_S_nonsm_misinfo_2_4==1 & SM_S_total2==1

/*take mean of responses if selected more than one*/

/*first replace with the values i want to average*/
replace SM_S_nonsm_misinfo_2_1=4 if SM_S_nonsm_misinfo_2_1==1 
replace SM_S_nonsm_misinfo_2_2=3 if SM_S_nonsm_misinfo_2_2==1 
replace SM_S_nonsm_misinfo_2_3=2 if SM_S_nonsm_misinfo_2_3==1 
replace SM_S_nonsm_misinfo_2_4=1 if SM_S_nonsm_misinfo_2_4==1 

/*then take mean and replace into new variable*/
egen SM_S_nonsm_misinfo_2_mean=rowmean(SM_S_nonsm_misinfo_2_*) if SM_S_total2==2
replace SM_S_nonsm_misinfo_2=SM_S_nonsm_misinfo_2_mean if SM_S_total2==2
su SM_S_nonsm_misinfo_2

drop old*

/*take mean of all false SM tweets - note * indicates wildcard so selecting all variables with those strings below*/ 
egen false_SM=rowmean(*_china_misinf* *chi_misinfo* *_sm_serbia_misinf* *_serb_misinf* *_sm_generic_misinf* *_gen_misinf*)
su false_SM

/*take mean of all false SM tweets*/
egen true_SM=rowmean(NT_sm_china_true NT_sm_generic_true NT_sm_serbia_true FC_sm_china_true FC_sm_generic_true FC_sm_serbia_true SM_C_china_true SM_C_gen_true SM_C_serb_true SM_S_chi_true SM_S_gen_true SM_S_serb_true SM_N_chi_true SM_N_gen_true SM_N_serb_true)
su true_SM

/*calculate position of first FC seen by taking the minimum of all variables indicating position of FCs shown to respondent*/
egen FCpos=rowmin(Fact_CheckTreatment_DO_FC_nonsm6 Fact_CheckTreatment_DO_FC_nonsm7 Fact_CheckTreatment_DO_FC_nonsm8 Fact_CheckTreatment_DO_FC_sm_ch0 Fact_CheckTreatment_DO_FC_sm_ge0 Fact_CheckTreatment_DO_FC_sm_ser)
su FCpos

/*make new version of all true variables in FC condition for post-FC analysis*/
foreach var of varlist FC_sm_china_true FC_sm_serbia_true FC_sm_generic_true FC_nonsm_true_* {
		gen `var'_postFC=`var'
		}

/*replace these new versions of true variables to missing if seen before first FC*/
replace FC_sm_china_true_postFC=. if Fact_CheckTreatment_DO_FC_sm_chi<FCpos & FC==1
replace FC_sm_serbia_true_postFC=. if Fact_CheckTreatment_DO_FC_sm_se0<FCpos & FC==1
replace FC_sm_generic_true_postFC=. if Fact_CheckTreatment_DO_FC_sm_gen<FCpos & FC==1
replace FC_nonsm_true_7_postFC=. if Fact_CheckTreatment_DO_FC_nonsm5<FCpos & FC==1
replace FC_nonsm_true_6_postFC=. if Fact_CheckTreatment_DO_FC_nonsm4<FCpos & FC==1
replace FC_nonsm_true_5_postFC=. if Fact_CheckTreatment_DO_FC_nonsm3<FCpos & FC==1
replace FC_nonsm_true_4_postFC=. if Fact_CheckTreatment_DO_FC_nonsm2<FCpos & FC==1
replace FC_nonsm_true_3_postFC=. if Fact_CheckTreatment_DO_FC_nonsm1<FCpos & FC==1
replace FC_nonsm_true_2_postFC=. if Fact_CheckTreatment_DO_FC_nonsm0<FCpos & FC==1
replace FC_nonsm_true_1_postFC=. if Fact_CheckTreatment_DO_FC_nonsm_<FCpos & FC==1

/*take mean of remaining values (i.e., mean of accuracy ratings of true headlines seen after first FC)*/
egen true_post_FC=rowmean(*_postFC) 
su true_post_FC

egen true_post_FC_SM=rowmean(FC_sm_china_true_postFC FC_sm_serbia_true_postFC FC_sm_generic_true_postFC) 
egen true_post_FC_nonSM=rowmean(FC_nonsm_true_*_postFC) 

/*fill in rest of values as mean of all true headlines seen in other conditions*/
egen truemean=rowmean(NT_nonsm_tru* NT_sm_china_true NT_sm_generic_true NT_sm_serbia_true SM_S_nonsm_tru* SM_S_chi_true SM_S_gen_true SM_S_serb_true SM_C_nonsm_tru* SM_C_china_true SM_C_gen_true SM_C_serb_true SM_N_nonsm_tru* SM_N_chi_true SM_N_gen_true SM_N_serb_true) 
su truemean 

replace true_post_FC=truemean if true_post_FC==.
su true_post_FC

egen truemean_SM=rowmean(NT_sm_china_true NT_sm_generic_true NT_sm_serbia_true SM_S_chi_true SM_S_gen_true SM_S_serb_true SM_C_china_true SM_C_gen_true SM_C_serb_true SM_N_chi_true SM_N_gen_true SM_N_serb_true) 

replace true_post_FC_SM=truemean_SM if true_post_FC_SM==.
su true_post_FC_SM

egen truemean_nonSM=rowmean(NT_nonsm_tru* SM_S_nonsm_tru* SM_C_nonsm_tru* SM_N_nonsm_tru*) 

replace true_post_FC_nonSM=truemean_nonSM if true_post_FC_nonSM==.
su true_post_FC_nonSM

*the favorability of the Global Times on a four-point scale where 1 = "Very unfavorable" and 4 = "Very favorable" (GT_fav).

gen GT_fav=abs(globaltimes_trust-5) /*flip scale*/
tab GT_fav
	
/*
We will use a lasso variable selection procedure to determine the set of prognostic covariates to include in each model (i.e., separately for each model below). If one or more levels (e.g., age group "18-24") are selected from a factor variable, we will include only the selected level(s) in the model. Below is the set of candidate variables that we will select from (as measured pretreatment) -- if not otherwise stated, these variables will be treated as continuous:
Education (college graduate indicator) (factor variable)
Age group (18-24, 25-34, 35-44, 45-54, 55-64, 65+) (factor variable)
Male (1/0) (factor variable)
Political interest (five-point)
Non-Hispanic white (1/0) (factor variable)
Twitter usage level (seven-point)
Twitter political news consumption frequency (seven-point)
Media outlet familiarity (indicators for each outlet listed; factor variables)
Serbia favorability (four-point)
China favorability (four-point)
Media trust (four-point)
State media trust (four-point)
Fact-checker trust (four-point)
*/

/*replace unselected variables to 0 so that 1=said they are familiar, 0=they are not*/
foreach var of varlist globaltimes_check_1-globaltimes_check_12 	{
											replace `var'=0 if `var'==.
											}

tab age,gen(age)								
											
*select controls for each DV using lasso with crossvalidation - local variable stores names of selected variables
lasso linear false_SM college age2-age8 male pol_interest nonhisp_white twitter_usage twitter_pol_usage globaltimes_check_1-globaltimes_check_12 Serbia_feelings China_feelings media_trust state_media_trust fact_check_trust, rseed(1234)
local falseSM_controls=e(allvars_sel) 
lasso linear true_SM college age2-age8 male pol_interest nonhisp_white twitter_usage twitter_pol_usage globaltimes_check_1-globaltimes_check_12 Serbia_feelings China_feelings media_trust state_media_trust fact_check_trust, rseed(1234)
local trueSM_controls=e(allvars_sel) 
lasso linear true_post_FC college age2-age8 male pol_interest nonhisp_white twitter_usage twitter_pol_usage globaltimes_check_1-globaltimes_check_12 Serbia_feelings China_feelings media_trust state_media_trust fact_check_trust, rseed(1234)
local true_post_FC_controls=e(allvars_sel) 
lasso linear GT_fav college age2-age8 male pol_interest nonhisp_white twitter_usage twitter_pol_usage globaltimes_check_1-globaltimes_check_12 Serbia_feelings China_feelings media_trust state_media_trust fact_check_trust, rseed(1234)
local GT_fav_controls=e(allvars_sel) 

/*
To test H1a, H1b, H1c, and H2 and answer RQ4 we will estimate a model at the respondent level of the form 

Y=B0+B1*Serbia_SM+B2*China_SM+B3*SM+B4*FC 

where Y=mean perceived accuracy of false tweets from a state media outlet (false_SM).

The coefficients B1, B2, and B3 will test H1a and B4 will test H1b. B1-B4, B2-B4, and B3-B4 will test H1c. B1-B2 will test H3. B1-B3 and B2-B3 will answer RQ4.
*/

*uncomment and run this code below to install estout
*net describe st0085_2, from(http://www.stata-journal.com/software/sj14-2)
*net install st0085_2.pkg, replace

reg false_SM Serbia_SM China_SM unlabeled_SM FC, robust
lincom FC-China_SM
lincom FC-Serbia_SM
lincom FC-unlabeled_SM
lincom China_SM-Serbia_SM
lincom Serbia_SM-unlabeled_SM
lincom China_SM-unlabeled_SM

reg false_SM Serbia_SM China_SM unlabeled_SM FC `falseSM_controls', robust
est store A
lincom FC-China_SM
lincom FC-Serbia_SM
lincom FC-unlabeled_SM
lincom China_SM-Serbia_SM
lincom Serbia_SM-unlabeled_SM
lincom China_SM-unlabeled_SM

/*define and label condition variable*/
gen cond=.
replace cond=1 if treatment_group==1
replace cond=2 if FC==1
replace cond=3 if China_SM==1
replace cond=4 if Serbia_SM==1
replace cond=5 if unlabeled_SM==1

label def condlab 1 "None" 2 "Fact check" 3 "China tag" 4 "Serbia tag" 5 "Unnamed country"
label val cond condlab

*uncomment and run this code below to install plotplain
*net describe gr0070, from(http://www.stata-journal.com/software/sj17-3)
*net install gr0070.pkg, replace

cibar false_SM,over1(cond) graphopts(scheme(plotplainblind) ytitle("Mean perceived accuracy") xtitle("Condition") legend(ring(0) position(2) bmargin(large) title("Type of tag/label",size(*.8))) yscale(r(1 4)) ylabel(1 "Not at all accurate" 2 "Not very accurate" 3 "Somewhat accurate" 4 "Very accurate")) 
graph export "false_SM1.pdf", replace

cibar false_SM,over1(cond) graphopts(scheme(plotplainblind) legend(off) ytitle("") yscale(r(1 4)) ylabel(1 "Not at all accurate" 2 "Not very accurate" 3 "Somewhat accurate" 4 "Very accurate") xlabel(1 "None" 2 `" "Fact check" "label" "' 3 `" "China state" "media tag" "' 4 `" "Serbia state" "media tag" "' 5 `" "Generic state" "media tag" "')) 
graph export "false_SM1b.pdf", replace

/*
To test H1a/H1b, we will also estimate a pooled model of the form 

Y=B0+B1*SM_all+B2*FC 

where Y=mean perceived accuracy of false tweets from a state media outlet (false_SM).
*/

reg false_SM SM_all FC, robust

reg false_SM SM_all FC `falseSM_controls', robust
lincom FC-SM_all
est store B

/*define and label simplified SM variable*/
gen cond2=.
replace cond2=1 if treatment_group==1
replace cond2=2 if FC==1
replace cond2=3 if unlabeled_SM==1 | China_SM==1 | Serbia_SM==1

label def condlab2 1 "None" 2 "Fact check label" 3 "State media tag (any)"
label val cond2 condlab2

cibar false_SM,over1(cond2) graphopts(scheme(plotplainblind) ytitle("Mean perceived accuracy") xtitle("Condition") legend(ring(0) position(2) bmargin(large) title("Type of tag/label",size(*.8))) yscale(r(1 4)) ylabel(1 "Not at all accurate" 2 "Not very accurate" 3 "Somewhat accurate" 4 "Very accurate")) 
graph export "false_SM2.pdf", replace

cibar false_SM,over1(cond2) graphopts(scheme(plotplainblind) legend(off) ytitle("") yscale(r(1 4)) ylabel(1 "Not at all accurate" 2 "Not very accurate" 3 "Somewhat accurate" 4 "Very accurate") xlabel(1 "None" 2 `" "Fact check" "label" "' 3 `" "Any state" "media tag" "')) 
graph export "false_SM2b.pdf", replace

/*
To test H3 and answer RQ4, we will estimate a model at the respondent level of the form 

Y=B0+B1*Serbia_SM+B2*China_SM+B3*SM+B4*FC 

where Y=mean perceived accuracy of true tweets from a state media outlet (true_SM).

The coefficients B1, B2, and B3 will test H3. B1-B3 and B2-B3 will answer RQ4.
*/

reg true_SM Serbia_SM China_SM unlabeled_SM FC, robust
lincom Serbia_SM-unlabeled_SM
lincom China_SM-unlabeled_SM

reg true_SM Serbia_SM China_SM unlabeled_SM FC `trueSM_controls', robust
est store true1
lincom Serbia_SM-unlabeled_SM
lincom China_SM-unlabeled_SM

cibar true_SM,over1(cond) graphopts(scheme(plotplainblind)) 
graph export "true_SM.pdf", replace

/*write out regression table*/
estout true1, label style(tex) replace varwidth(25) collabels("") cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(r2 N, fmt(%9.2f %9.0f) labels("R$^{2}$" "N")) starlevels(* 0.10 ** 0.05 *** 0.01) 

*exploratory SM trust moderator
preserve
replace state_media_trust=3 if state_media_trust==4

reg false_SM Serbia_SM##i.state_media_trust China_SM##i.state_media_trust unlabeled_SM##i.state_media_trust FC `falseSM_controls', robust
est store A
lincom 1.Serbia_SM+1.Serbia_SM#2.state_media_trust
lincom 1.Serbia_SM+1.Serbia_SM#3.state_media_trust
lincom 1.China_SM+1.China_SM#2.state_media_trust
lincom 1.China_SM+1.China_SM#3.state_media_trust

reg false_SM Serbia_SM##c.state_media_trust China_SM##c.state_media_trust unlabeled_SM##c.state_media_trust FC `falseSM_controls', robust
lincom 1.Serbia_SM+1.Serbia_SM#state_media_trust
lincom 1.Serbia_SM+2*1.Serbia_SM#state_media_trust
lincom 1.Serbia_SM+3*1.Serbia_SM#state_media_trust
lincom 1.China_SM+1*1.China_SM#state_media_trust
lincom 1.China_SM+2*1.China_SM#state_media_trust
lincom 1.China_SM+3*1.China_SM#state_media_trust

reg true_SM Serbia_SM##i.state_media_trust China_SM##i.state_media_trust unlabeled_SM##i.state_media_trust FC `falseSM_controls', robust
est store B
lincom 1.Serbia_SM+1.Serbia_SM#2.state_media_trust
lincom 1.Serbia_SM+1.Serbia_SM#3.state_media_trust
lincom 1.China_SM+1.China_SM#2.state_media_trust
lincom 1.China_SM+1.China_SM#3.state_media_trust

estout A B, label style(tex) replace varwidth(25) collabels("") cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(r2 N, fmt(%9.2f %9.0f) labels("R$^{2}$" "N")) starlevels(* 0.10 ** 0.05 *** 0.01) 

reg true_SM Serbia_SM##c.state_media_trust China_SM##c.state_media_trust unlabeled_SM##c.state_media_trust FC `falseSM_controls', robust
lincom 1.Serbia_SM+1.Serbia_SM#state_media_trust
lincom 1.Serbia_SM+2*1.Serbia_SM#state_media_trust
lincom 1.Serbia_SM+3*1.Serbia_SM#state_media_trust
lincom 1.China_SM+1*1.China_SM#state_media_trust
lincom 1.China_SM+2*1.China_SM#state_media_trust
lincom 1.China_SM+3*1.China_SM#state_media_trust

bysort state_media_trust: reg false_SM Serbia_SM China_SM unlabeled_SM FC, robust

restore

/*
To test H4, we will estimate a model at the respondent level of the form

Y=B0+B1*Serbia_SM+B2*China_SM+B3*SM+B4*FC 

where Y=perceived favorability of the Global Times (GT_fav).

The coefficients B1, B2, and B3 will test H4. We will also estimate a pooled model of the form 

Y=B0+B1*SM_all+B2*FC 

where Y=perceived favorability of the Global Times (GT_fav).
*/

reg GT_fav Serbia_SM China_SM unlabeled_SM FC, robust

reg GT_fav Serbia_SM China_SM unlabeled_SM FC `GT_fav_controls', robust
est store C
lincom FC-China_SM
lincom FC-Serbia_SM
lincom FC-unlabeled_SM
lincom China_SM-Serbia_SM

cibar GT_fav,over1(cond) graphopts(scheme(plotplainblind)) 
graph export "GT_fav.pdf", replace

reg GT_fav SM_all FC, robust

reg GT_fav SM_all FC `GT_fav_controls', robust
est store D
lincom FC-SM_all

cibar GT_fav,over1(cond2) graphopts(scheme(plotplainblind)) 
graph export "GT_fav2.pdf", replace

/*write out regression table*/
estout A B C D, label style(tex) replace varwidth(25) collabels("") cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(r2 N, fmt(%9.2f %9.0f) labels("R$^{2}$" "N")) starlevels(* 0.10 ** 0.05 *** 0.01) 

/*To answer RQ1, we will estimate versions of the models listed above for H1-H4 among only people who identify with or lean toward one of the two major parties. For each of these models, we will add an indicator for Republicans and separate interactions between the Republican indicator and each of the treatment variables. 
*/

reg false_SM Serbia_SM##rep China_SM##rep unlabeled_SM##rep FC##rep if dem==1 | rep==1, robust

reg false_SM Serbia_SM##rep China_SM##rep unlabeled_SM##rep FC##rep `falseSM_controls' if dem==1 | rep==1, robust
est store A

gen rep2=rep
label def replab 0 "Democrat" 1 "Republican"
label val rep2 replab

cibar false_SM if dem==1 | rep==1,over1(cond) over2(rep2) graphopts(scheme(plotplainblind)) 
graph export "false_SM_party.pdf", replace

reg false_SM SM_all##rep FC##rep if dem==1 | rep==1, robust

reg false_SM SM_all##rep FC##rep `falseSM_controls' if dem==1 | rep==1, robust
est store B

cibar false_SM if dem==1 | rep==1,over1(cond2) over2(rep2) graphopts(scheme(plotplainblind)) 
graph export "false_SM_party2.pdf", replace

reg true_SM Serbia_SM##rep China_SM##rep unlabeled_SM##rep FC##rep if dem==1 | rep==1, robust

reg true_SM Serbia_SM##rep China_SM##rep unlabeled_SM##rep FC##rep `trueSM_controls' if dem==1 | rep==1, robust
est store C

cibar true_SM if dem==1 | rep==1,over1(cond2) over2(rep2) graphopts(scheme(plotplainblind)) 
graph export "true_SM_party2.pdf", replace

reg GT_fav Serbia_SM##rep China_SM##rep unlabeled_SM##rep FC##rep if dem==1 | rep==1, robust

reg GT_fav Serbia_SM##rep China_SM##rep unlabeled_SM##rep FC##rep `GT_fav_controls' if dem==1 | rep==1, robust
est store D

cibar GT_fav if dem==1 | rep==1,over1(cond) over2(rep2) graphopts(scheme(plotplainblind)) 
graph export "GT_fav_party.pdf", replace

reg GT_fav SM_all##rep FC##rep if dem==1 | rep==1, robust

reg GT_fav SM_all##rep FC##rep `GT_fav_controls' if dem==1 | rep==1, robust
est store E

cibar GT_fav if dem==1 | rep==1,over1(cond2) over2(rep2) graphopts(scheme(plotplainblind)) 
graph export "GT_fav_party2.pdf", replace

/*write out regression table*/
estout A B C D E, label style(tex) replace varwidth(25) collabels("") cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(r2 N, fmt(%9.2f %9.0f) labels("R$^{2}$" "N")) starlevels(* 0.10 ** 0.05 *** 0.01) 

/*
To answer RQ3, we will estimate a model at the headline (CORRECTION: RESPONDENT) level of the form 

Y=B0+B1*Serbia_SM+B2*China_SM+B3*SM+B4*FC+B5*SM_source+B6*Serbia_SM x SM_source+B7*China_SM x SM_source+B8*SM x SM_source [CORRECTED - see Slack]

where Y=mean perceived accuracy of true tweets seen by a respondent after the first fact-check tweet that they see (true_post_FC) and SM_source is an indicator for a tweet from the Global Times.

B4 will answer RQ3.
*/

reg true_post_FC Serbia_SM China_SM unlabeled_SM FC, robust

reg true_post_FC Serbia_SM China_SM unlabeled_SM FC `true_post_FC_controls', robust
est store RQ3a

cibar true_post_FC,over1(cond) graphopts(scheme(plotplainblind)) 
graph export "true_post_FC.pdf", replace

reg true_post_FC_SM Serbia_SM China_SM unlabeled_SM FC, robust
reg true_post_FC_nonSM Serbia_SM China_SM unlabeled_SM FC, robust

/*
To answer RQ5, we will estimate a model at the respondent level of the form

Y=B0+B1*Serbia_SM+B2*China_SM+B3*SM+B4*FC+B5*Serbia_feelings+B5*Serbia_SM x Serbia_feelings+B6*China_feelings+B7*China_SM x China_feelings

where Y=mean perceived accuracy of true tweets from state media sources (true_SM) and a separate model where Y=mean perceived accuracy of false tweets from state media sources (false_SM).
*/

reg true_SM Serbia_SM##c.Serbia_feelings China_SM##c.China_feelings unlabeled_SM FC, robust

reg true_SM Serbia_SM##c.Serbia_feelings China_SM##c.China_feelings unlabeled_SM FC `trueSM_controls', robust
est store B

reg true_SM Serbia_SM##i.Serbia_feelings China_SM##i.China_feelings unlabeled_SM FC `trueSM_controls', robust

gen serbia_warm=(Serbia_feelings>2 & Serbia_feelings!=.)

label def warmlab 0 "Serbia cold" 1 "Serbia warm"
label val serbia_warm warmlab

gen china_warm=(China_feelings>2 & China_feelings!=.)

label def warmlab2 0 "China cold" 1 "China warm"
label val china_warm warmlab2

cibar true_SM,over1(cond) over2(serbia_warm) graphopts(scheme(plotplainblind)) 
graph export "true_SM_Serbia_feelings.pdf", replace

cibar true_SM,over1(cond) over2(china_warm) graphopts(scheme(plotplainblind)) 
graph export "true_SM_China_feelings.pdf", replace

reg false_SM Serbia_SM##c.Serbia_feelings China_SM##c.China_feelings unlabeled_SM FC, robust

reg false_SM Serbia_SM##c.Serbia_feelings China_SM##c.China_feelings unlabeled_SM FC `falseSM_controls', robust
est store A

cibar false_SM,over1(cond) over2(serbia_warm) graphopts(scheme(plotplainblind)) 
graph export "false_SM_Serbia_feelings.pdf", replace

cibar false_SM,over1(cond) over2(china_warm) graphopts(scheme(plotplainblind)) 
graph export "false_SM_China_feelings.pdf", replace

reg false_SM Serbia_SM##i.Serbia_feelings China_SM##i.China_feelings unlabeled_SM FC `falseSM_controls', robust

/*write out regression table*/
estout A B, label style(tex) replace varwidth(25) collabels("") cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(r2 N, fmt(%9.2f %9.0f) labels("R$^{2}$" "N")) starlevels(* 0.10 ** 0.05 *** 0.01) 

*headline level analyses

/*make a new column for perceived accuracy of false China-related SM tweet and fill in from each of five conditions*/
gen false_SM_tweet1=.
replace false_SM_tweet1=NT_sm_china_misinfo if NT_sm_china_misinfo!=.
replace false_SM_tweet1=FC_sm_china_misinfo if FC_sm_china_misinfo!=.
replace false_SM_tweet1=SM_C_china_misinfo if SM_C_china_misinfo!=.
replace false_SM_tweet1=SM_S_chi_misinfo if SM_S_chi_misinfo!=.
replace false_SM_tweet1=SM_N_chi_misinfo if SM_N_chi_misinfo!=.

/*make a new column for perceived accuracy of false Serbia-related SM tweet and fill in from each of five conditions*/
gen false_SM_tweet2=.
replace false_SM_tweet2=NT_sm_serbia_misinfo if NT_sm_serbia_misinfo!=.
replace false_SM_tweet2=FC_sm_serbia_misinfo if FC_sm_serbia_misinfo!=.
replace false_SM_tweet2=SM_S_serb_misinfo if SM_S_serb_misinfo!=.
replace false_SM_tweet2=SM_C_serb_misinfo if SM_C_serb_misinfo!=.
replace false_SM_tweet2=SM_N_serb_misinfo if SM_N_serb_misinfo!=.

/*make a new column for perceived accuracy of false generic SM tweet and fill in from each of five conditions*/
gen false_SM_tweet3=.
replace false_SM_tweet3=NT_sm_generic_misinf if NT_sm_generic_misinf!=.
replace false_SM_tweet3=FC_sm_generic_misinf if FC_sm_generic_misinf!=.
replace false_SM_tweet3=SM_C_gen_misinfo if SM_C_gen_misinfo!=.
replace false_SM_tweet3=SM_S_gen_misinfo if SM_S_gen_misinfo!=.
replace false_SM_tweet3=SM_N_gen_misinfo if SM_N_gen_misinfo!=.

/*save the data in this state to revert after reshape*/
preserve

/*reshape it to long (pivot)*/
reshape long false_SM_tweet, i(ResponseId) j(tweetnum) 

/*
… Serbia_tweet equals 1 if the tweet in question concerns Serbia and 0 otherwise. 

… China_tweet equals 1 if the tweet in question concerns China and 0 otherwise. 

… SM_source equals 1 for a tweet from the Global Times and 0 otherwise. [NOT NEEDED]
*/

gen Serbia_tweet=(tweetnum==2)

gen China_tweet=(tweetnum==1)

save "false_SM_tweet-long.dta", replace

/*lasso again*/
lasso linear false_SM_tweet college age2-age8 male pol_interest nonhisp_white twitter_usage twitter_pol_usage globaltimes_check_1-globaltimes_check_12 Serbia_feelings China_feelings media_trust state_media_trust fact_check_trust, rseed(1234)
local falseSM_tweet_controls=e(allvars_sel) 

/*
To answer RQ2, we will estimate a model at the headline level of the form 

Y=B0+B1*Serbia_SM+B2*China_SM+B3*SM+B4*FC+B5*Serbia_tweet+B6*Serbia_SM x Serbia_tweet+B7*China_tweet+B8*China_SM*China_tweet

where Y=perceived accuracy of a false state media tweet, Serbia_tweet is an indicator for whether the tweet in question concerns Serbia, and China_tweet is an indicator for whether the tweet in question concerns China.

B6 and B8 will answer RQ2.*/

reg false_SM_tweet Serbia_SM##Serbia_tweet China_SM##China_tweet unlabeled_SM FC, robust cluster(ResponseId)

reg false_SM_tweet Serbia_SM##Serbia_tweet China_SM##China_tweet unlabeled_SM FC `falseSM_tweet_controls', robust cluster(ResponseId)
est store A

/*write out regression table*/
estout A, label style(tex) replace varwidth(25) collabels("") cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(r2 N, fmt(%9.2f %9.0f) labels("R$^{2}$" "N")) starlevels(* 0.10 ** 0.05 *** 0.01) 

gen tweettype=.
replace tweettype=1 if Serbia_tweet==1
replace tweettype=2 if China_tweet==1
replace tweettype=3 if Serbia_tweet==0 & China_tweet==0

label def tweetlab 1 "Serbia tweet" 2 "China tweet" 3 "Neither"
label val tweettype tweetlab

cibar false_SM_tweet,over1(cond) over2(tweettype) graphopts(scheme(plotplainblind)) 
graph export "false_SM_Serbia_China_tweet.pdf", replace

/*bring back the data in the form it was in before reshape*/
restore


*EXPLORATORY extension of RQ2

/*make a new column for perceived accuracy of true China-related SM tweet and fill in from each of five conditions*/
gen true_SM_tweet1=.
replace true_SM_tweet1=NT_sm_china_true if NT_sm_china_true!=.
replace true_SM_tweet1=FC_sm_china_true if FC_sm_china_true!=.
replace true_SM_tweet1=SM_C_china_true if SM_C_china_true!=.
replace true_SM_tweet1=SM_S_chi_true if SM_S_chi_true!=.
replace true_SM_tweet1=SM_N_chi_true if SM_N_chi_true!=.

/*make a new column for perceived accuracy of true Serbia-related SM tweet and fill in from each of five conditions*/
gen true_SM_tweet2=.
replace true_SM_tweet2=NT_sm_serbia_true if NT_sm_serbia_true!=.
replace true_SM_tweet2=FC_sm_serbia_true if FC_sm_serbia_true!=.
replace true_SM_tweet2=SM_S_serb_true if SM_S_serb_true!=.
replace true_SM_tweet2=SM_C_serb_true if SM_C_serb_true!=.
replace true_SM_tweet2=SM_N_serb_true if SM_N_serb_true!=.

/*make a new column for perceived accuracy of true generic SM tweet and fill in from each of five conditions*/
gen true_SM_tweet3=.
replace true_SM_tweet3=NT_sm_generic_misinf if NT_sm_generic_misinf!=.
replace true_SM_tweet3=FC_sm_generic_misinf if FC_sm_generic_misinf!=.
replace true_SM_tweet3=SM_C_gen_true if SM_C_gen_true!=.
replace true_SM_tweet3=SM_S_gen_true if SM_S_gen_true!=.
replace true_SM_tweet3=SM_N_gen_true if SM_N_gen_true!=.

/*save the data in this state to revert after reshape*/
preserve

/*reshape it to long (pivot)*/
reshape long true_SM_tweet, i(ResponseId) j(tweetnum) 

/*
… Serbia_tweet equals 1 if the tweet in question concerns Serbia and 0 otherwise. 

… China_tweet equals 1 if the tweet in question concerns China and 0 otherwise. 

… SM_source equals 1 for a tweet from the Global Times and 0 otherwise. [NOT NEEDED]
*/

gen Serbia_tweet=(tweetnum==2)

gen China_tweet=(tweetnum==1)

save "true_SM_tweet-long.dta", replace

/*lasso again*/
lasso linear true_SM_tweet college age2-age8 male pol_interest nonhisp_white twitter_usage twitter_pol_usage globaltimes_check_1-globaltimes_check_12 Serbia_feelings China_feelings media_trust state_media_trust fact_check_trust, rseed(1234)
local trueSM_tweet_controls=e(allvars_sel) 

reg true_SM_tweet Serbia_SM##Serbia_tweet China_SM##China_tweet unlabeled_SM FC, robust cluster(ResponseId)

reg true_SM_tweet Serbia_SM##Serbia_tweet China_SM##China_tweet unlabeled_SM FC `falseSM_tweet_controls', robust cluster(ResponseId)

/*bring back the data in the form it was in before reshape*/
restore


/*save data state again*/
preserve

/*do headline-level version of RQ3*/

/*make a new column for perceived accuracy of true China-related SM tweet and fill in from each of five conditions*/
gen true_tweet1=.
replace true_tweet1=NT_sm_china_true if NT_sm_china_true!=.
replace true_tweet1=FC_sm_china_true if FC_sm_china_true!=.
replace true_tweet1=SM_C_china_true if SM_C_china_true!=.
replace true_tweet1=SM_S_chi_true if SM_S_chi_true!=.
replace true_tweet1=SM_N_chi_true if SM_N_chi_true!=.

/*make a new column for perceived accuracy of true Serbia-related SM tweet and fill in from each of five conditions*/
gen true_tweet2=.
replace true_tweet2=NT_sm_serbia_true if NT_sm_serbia_true!=.
replace true_tweet2=FC_sm_serbia_true if FC_sm_serbia_true!=.
replace true_tweet2=SM_S_serb_true if SM_S_serb_true!=.
replace true_tweet2=SM_C_serb_true if SM_C_serb_true!=.
replace true_tweet2=SM_N_serb_true if SM_N_serb_true!=.

/*make a new column for perceived accuracy of true generic SM tweet and fill in from each of five conditions*/
gen true_tweet3=.
replace true_tweet3=NT_sm_generic_true if NT_sm_generic_true!=.
replace true_tweet3=FC_sm_generic_true if FC_sm_generic_true!=.
replace true_tweet3=SM_C_gen_true if SM_C_gen_true!=.
replace true_tweet3=SM_S_gen_true if SM_S_gen_true!=.
replace true_tweet3=SM_N_gen_true if SM_N_gen_true!=.

/*make a new column for each of 7 non-SM true tweets and fill in*/
forval i=1/7 	{
				local j=`i'+3
				gen true_tweet`j'=.
				replace true_tweet`j'=NT_nonsm_true_`i' if NT_nonsm_true_`i'!=. 
				replace true_tweet`j'=FC_nonsm_true_`i' if FC_nonsm_true_`i'!=.
				replace true_tweet`j'=SM_S_nonsm_true_`i' if SM_S_nonsm_true_`i'!=.
				replace true_tweet`j'=SM_C_nonsm_true_`i' if SM_C_nonsm_true_`i'!=. 
				replace true_tweet`j'=SM_N_nonsm_true_`i' if SM_N_nonsm_true_`i'!=.
				}
		
forval i=1/10 	{
				reg true_tweet`i' Serbia_SM China_SM unlabeled_SM FC, robust
				}
		
/*reshape it to long (pivot)*/
reshape long true_tweet, i(ResponseId) j(tweetnum) 

/*
original:

Y=B0+B1*Serbia_SM+B2*China_SM+B3*SM+B4*FC+B5*SM_source+B6*Serbia_SM x SM_source+B7*China_SM x SM_source+B8*SM x SM_source 

estimated headline level (1 row = 1 true headline): Define post_FC=1 if seen after a FC, 0 otherwise.
*/

gen SM_source=tweetnum<4

/*make indicator for whether the tweet in question appeared after the first FC seen by the respondent (FCpos variable made above)*/
gen post_FC=0
replace post_FC=1 if FC==1 & tweetnum==1 & Fact_CheckTreatment_DO_FC_sm_chi>FCpos
replace post_FC=1 if FC==1 & tweetnum==2 & Fact_CheckTreatment_DO_FC_sm_se0>FCpos
replace post_FC=1 if FC==1 & tweetnum==3 & Fact_CheckTreatment_DO_FC_sm_gen>FCpos
replace post_FC=1 if FC==1 & tweetnum==4 & Fact_CheckTreatment_DO_FC_nonsm_>FCpos
replace post_FC=1 if FC==1 & tweetnum==5 & Fact_CheckTreatment_DO_FC_nonsm0>FCpos
replace post_FC=1 if FC==1 & tweetnum==6 & Fact_CheckTreatment_DO_FC_nonsm1>FCpos
replace post_FC=1 if FC==1 & tweetnum==7 & Fact_CheckTreatment_DO_FC_nonsm2>FCpos
replace post_FC=1 if FC==1 & tweetnum==8 & Fact_CheckTreatment_DO_FC_nonsm3>FCpos
replace post_FC=1 if FC==1 & tweetnum==9 & Fact_CheckTreatment_DO_FC_nonsm4>FCpos
replace post_FC=1 if FC==1 & tweetnum==10 & Fact_CheckTreatment_DO_FC_nonsm5>FCpos

save "true_tweet-long.dta", replace

lasso linear true_tweet college age2-age8 male pol_interest nonhisp_white twitter_usage twitter_pol_usage globaltimes_check_1-globaltimes_check_12 Serbia_feelings China_feelings media_trust state_media_trust fact_check_trust, rseed(1234)
local true_tweet_controls=e(allvars_sel) 

bysort SM_source: reg true_tweet Serbia_SM China_SM unlabeled_SM FC post_FC, robust cluster(ResponseId)

reg true_tweet Serbia_SM##SM_source China_SM##SM_source unlabeled_SM##SM_source FC post_FC, robust cluster(ResponseId)

reg true_tweet Serbia_SM##SM_source China_SM##SM_source unlabeled_SM##SM_source FC post_FC `true_tweet_controls', robust cluster(ResponseId)
est store RQ3b

/*write out regression table*/
estout RQ3b, label style(tex) replace varwidth(25) collabels("") cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(r2 N, fmt(%9.2f %9.0f) labels("R$^{2}$" "N")) starlevels(* 0.10 ** 0.05 *** 0.01) 

label def sourcelab 0 "Not SM source" 1 "SM source"
label val SM_source sourcelab

cibar true_tweet,over1(cond) over2(SM_source) graphopts(scheme(plotplainblind)) 
graph export "true_tweet_SM_source.pdf", replace

collapse (mean) true_tweet Serbia_SM China_SM unlabeled_SM FC,by(ResponseId) 

reg true_tweet Serbia_SM China_SM unlabeled_SM FC, robust

restore

/*data quality indicators and context*/

tab GT_know
tab twitter_usage
tab twitter_pol_usage

/*manipulation checks*/

*measure 1: did they indicate seeing a particular type of tag/label or not?
gen saw_sm_tag=(manip_check_tag_1==1)
gen saw_fc_tag=(manip_check_tag_2==1)
gen saw_promoted_tag=(manip_check_tag_4==1)
gen saw_no_tag=(manip_check_tag_5==1)

foreach var of varlist saw_* 	{
								reg `var' Serbia_SM China_SM unlabeled_SM FC, robust
								}

bysort Serbia_SM China_SM unlabeled_SM FC: su saw_*

*measure 2: did they indicate seeing only the type of tag/label they actually saw (if any) or not?								
gen correct=.
replace correct=1 if treatment_group==1 & saw_sm_tag==0 & saw_fc_tag==0 & saw_promoted_tag==0 & saw_no_tag==1
replace correct=1 if SM_all==1 & saw_sm_tag==1 & saw_fc_tag==0 & saw_promoted_tag==0 & saw_no_tag==0
replace correct=1 if FC==1 & saw_sm_tag==0 & saw_fc_tag==1 & saw_promoted_tag==0 & saw_no_tag==0
replace correct=0 if correct==.

bysort Serbia_SM China_SM unlabeled_SM FC: su correct

bysort SM_all FC: su correct

reg correct Serbia_SM China_SM unlabeled_SM FC, robust

*note: people in China_SM saw FC so make alternate measure
gen correct2=.
replace correct2=1 if treatment_group==1 & saw_sm_tag==0 & saw_fc_tag==0 & saw_promoted_tag==0 & saw_no_tag==1
replace correct2=1 if Serbia_SM==1 & saw_sm_tag==1 & saw_fc_tag==0 & saw_promoted_tag==0 & saw_no_tag==0
replace correct2=1 if China_SM==1 & saw_sm_tag==1 & saw_promoted_tag==0 & saw_no_tag==0
replace correct2=1 if unlabeled_SM==1 & saw_sm_tag==1 & saw_fc_tag==0 & saw_promoted_tag==0 & saw_no_tag==0
replace correct2=1 if FC==1 & saw_sm_tag==0 & saw_fc_tag==1 & saw_promoted_tag==0 & saw_no_tag==0
replace correct2=0 if correct2==.

gen saw_sm_only=saw_sm_tag==1 & saw_fc_tag==0 & saw_promoted_tag==0 
gen saw_smfc=saw_sm_tag==1 & saw_fc_tag==1
gen saw_fc_only=saw_sm_tag==0 & saw_fc_tag==1 & saw_promoted_tag==0 
gen saw_other_mult=(saw_sm_tag==0 & saw_fc_tag==1 & saw_promoted_tag==1) | (saw_sm_tag==1 & saw_fc_tag==0 & saw_promoted_tag==1) | (saw_sm_tag==1 & saw_fc_tag==1 & saw_promoted_tag==1)

bysort treatment_group: su saw_sm_only saw_fc_only saw_smfc saw_other_mult 

bysort Serbia_SM China_SM unlabeled_SM FC: su correct2

bysort SM_all FC: su correct2

reg correct2 Serbia_SM China_SM unlabeled_SM FC, robust

/*IV reg using correct2 to create measures of compliance*/

foreach var of varlist Serbia_SM China_SM unlabeled_SM FC {
	gen `var'_treated=correct2*`var'
}

*uncomment and run this code below to install ivreg2
*net sj 7-4 st0030_3
*net install st0030_3.pkg, replace

ivreg2 false_SM `falseSM_controls' (*_treated=Serbia_SM China_SM unlabeled_SM FC), robust

/*attention check*/
gen attention=(manip_check_tweet_7==1)
tab attention
reg attention Serbia_SM China_SM unlabeled_SM FC, robust							

*attention by SM trust
bysort state_media_trust: su correct
bysort state_media_trust: su correct2
bysort state_media_trust: reg attention Serbia_SM China_SM unlabeled_SM FC, robust	
								
reg correct i.state_media_trust, robust					
reg correct2 i.state_media_trust, robust
reg attention i.state_media_trust, robust	

reg correct state_media_trust Serbia_SM China_SM unlabeled_SM FC, robust					
reg correct2 state_media_trust Serbia_SM China_SM unlabeled_SM FC, robust
reg attention state_media_trust Serbia_SM China_SM unlabeled_SM FC, robust					
	
reg correct c.state_media_trust##treatment_group, robust					
reg correct2 c.state_media_trust##treatment_group, robust			
reg attention c.state_media_trust##treatment_group, robust								
	
*total time spent
egen SM_N_time=rowtotal(SM_N_*_Page_Submit)	if SM_N_timer_1_Page_Submit!=.
egen SM_S_time=rowtotal(SM_S_*_Page_Submit)	if SM_S_timer_1_Page_Submit!=.
egen SM_C_time=rowtotal(SM_C_*_Page_Submit)	if SM_C_timer_1_Page_Submit!=.
egen FC_time=rowtotal(FC_*_Page_Submit)	if FC_timer_1_Page_Submit!=.
egen NT_time=rowtotal(NT_*_Page_Submit)	if NT_timer_1_Page_Submit!=.

egen tweet_time=rowtotal(*_time) if manip_check_timer_Page_Submit!=.
*winsorize at p95
su tweet_time, detail
replace tweet_time=546.732 if tweet_time>546.732 & tweet_time!=.

reg tweet_time state_media_trust Serbia_SM China_SM unlabeled_SM FC, robust					
reg tweet_time c.state_media_trust##treatment_group, robust			

tab troll
tab info_search

log close
